package com.nineclock.sign.controller;

import com.nineclock.sign.dto.SignInfoAllDTO;
import com.nineclock.sign.dto.SignPageDTO;
import com.nineclock.common.entity.PageResult;
import com.nineclock.common.entity.Result;
import com.nineclock.sign.dto.SignInfoDTO;
import com.nineclock.sign.service.SignInfoService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@RestController
public class SignInfoController {

    @Autowired(required = false)
    private SignInfoService signInfoService;

    /**
     * APP: 签到
     *
     * @param signInfoDTO
     * @return
     */
    @PostMapping("insert")
    @ApiOperation("APP: 签到")
    public Result insert(SignInfoDTO signInfoDTO) {
        signInfoService.insert(signInfoDTO);
        return Result.success();
    }

    /**
     * PC: 查询签到列表
     * 接口路径：GET/sign/sign
     */
    @GetMapping("/sign")
    @ApiOperation("PC: 查询签到列表")
    private Result<PageResult<SignPageDTO>> querySignInfoPage(String startTime, String endTime,
                                                              Integer page, Integer pageSize){
        PageResult<SignPageDTO> result= signInfoService.querySignInfoPage(startTime,endTime,page,pageSize);

        return Result.success(result);
    }

    /**
     * PC: 导出签到列表
     * 接口路径：GET/sign/export
     */
    @ApiOperation("PC: 导出签到列表")
    @GetMapping("/export")
    public void export(String startTime,String endTime) throws Exception {
        signInfoService.export(startTime,endTime);

    }
    /**
     * APP: 获取当前用户当天签到次数
     * 接口路径：GET/sign/getDayCount
     */
    @ApiOperation("APP: 获取当前用户当天签到次数")
    @GetMapping("/getDayCount")
    public Result<Integer> getDayCount(){
        Integer count = signInfoService.getDayCount();
        return Result.success(count);
    }

    /**
     * APP: 查询本月签到记录
     * 接口路径：GET/sign/pagingSignCurrentUserByMonth
     */
   /* @ApiOperation("APP: 查询本月签到记录")
    @GetMapping("pagingSignCurrentUserByMonth")
    public Result<List<SignInfoDTo>> pagingSignCurrentUserByMonth(){
        List<SignInfoDTo> signInfoDTo = singService.pagingSignCurrentUserByMonth();
        return Result.success(signInfoDTo);
    }*/


    /**
     * 接口名称：APP: 查询本月签到记录
     * 接口路径：GET/sign/pagingSignCurrentUserByMonth
     */
    @GetMapping("/pagingSignCurrentUserByMonth")
    @ApiOperation("PP: 查询本月签到记录")
    public Result<List<SignInfoDTO>> pagingSignCurrentUserByMonth(String dateStr) {
        List<SignInfoDTO> signInfoDTOList = signInfoService.pagingSignCurrentUserByMonth(dateStr);
        return Result.success(signInfoDTOList);
    }

    /**
     * 接口名称：APP: 获取团队员工打卡列表
     * 接口路径：GET/sign/listSignAllUser
     */
    @GetMapping("/listSignAllUser")
    @ApiOperation("APP: 获取团队员工打卡列表")
    public Result<List<SignInfoAllDTO>> listSignAllUser(String dateStr) {
        List<SignInfoAllDTO> signInfoAllDTOList = signInfoService.listSignAllUser(dateStr);
        return Result.success(signInfoAllDTOList);
    }

}